package Practice;

import java.util.HashMap;
import java.util.Scanner;

public class K_area {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),k = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        long[] prefixSum = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            prefixSum[i] = prefixSum[i - 1] + a[i - 1];
        }
        HashMap<Long,Integer> recount = new HashMap<>();
        recount.put(0L,1);
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            long num = (prefixSum[i] % k + k) %k;
            if (recount.containsKey(num)){
                ans += recount.get(num);
                recount.put(num,recount.get(num)+1);
            }
            else {
                recount.put(num,1);
            }

        }
        System.out.println(ans);
    }
}
